package java19_4_21.com.huweilong.thread_safe.exclusive;

/**
 * @author 是阿秋啊
 * @date 2022/04/24 17:44
 **/
public class Main {
    // 这个对象用来当锁对象
    static Object lock = new Object();

    static class MyThread1 extends Thread {
        @Override
        public void run() {
           // synchronized (lock) {
                for (int i = 0; i < 1000_0000; i++) {
                    System.out.println("我是张三");
                }
          //  }
        }
    }

    static class MyThread2 extends Thread {
        @Override
        public void run() {
          //  synchronized (lock) {
                for (int i = 0; i < 1000_0000; i++) {
                    System.out.println("我是李四");
                }
           // }
        }
    }

    public static void main(String[] args) {
        Thread t1 = new MyThread1();
        t1.start();


        Thread t2 = new MyThread2();
        t2.start();
    }
}
